package gui;
import ttt.*;
import javax.swing.event.*;

public class TextBasedBoard implements BoardUserInterface {

	private TicTacToe t;
	
	public void setTicTacToeBoard(TicTacToe t) {
		this.t = t;
	}
	
	public void drawBoard() {
		if(t == null)
			return;
		
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				String end;
				if(j == 2)
					end = "";
				else
					end = " |";
				
				System.out.print(" " + t.intToChar(t.getBoard()[i][j]) + end);
			}
			
			if(i == 2)
				System.out.println("\n");
			else
				System.out.println("\n-----------");
		}
	}
	
	public void stateChanged(ChangeEvent event) {
		drawBoard();
	}
}
